'use client'

import { useRouter } from 'next/navigation'

import { Button } from '../ui/button'

export default function LoginForm() {
  const router = useRouter()
  const handleLogin = async () => {
    const res = await fetch('/api/auth/login', {
      method: 'POST',
    })
    console.log('res', res)

    const data = await res.json()
    console.log('data', data)

    if (data.success) {
      return router.push('/protected/dashboard')
    }
  }
  return (
    <div>
      <Button onClick={handleLogin}>Login</Button>
    </div>
  )
}
